import { ref, Ref, WatchStopHandle } from "vue";

/**
 * 传感器
 */
export default class sensorData {
    private static instance: sensorData = new sensorData();
    /**
     * 传感器
     */
    public static get Default(): sensorData {
        return this.instance;
    }

    constructor() {
        window.addEventListener('unload', this.Dispose.bind(this));
    }

    Dispose() {
        window.removeEventListener('unload', this.Dispose);

        for (const watchStopHandle of this.watchStopHandles) {
            watchStopHandle();
        }
        this.watchStopHandles.clear();
    }
    public lon: Ref<string> = ref('116.48912');
    public lat: Ref<string> = ref('39.97889');
    //航向角
    public heading: Ref<string> = ref('100');
    //俯仰角
    public pitch: Ref<string> = ref('');
    //海拔
    public height_msl: Ref<string> = ref('');
    //卫星数量
    public num_sats_tracked: Ref<string> = ref('');
    
    public imageData_twelve: Ref<string> = ref('');
    public imageData_six: Ref<string> = ref('');

    private watchStopHandles: Array<WatchStopHandle> = [];

    public async Awake(): Promise<void> {
    }

    public async Destroy(): Promise<void> {
    }
}